import ProTable, { ProColumnType } from '@ant-design/pro-table';
import React from 'react';
import { useRequest } from 'ahooks';
import { apiActionLog } from '@/api/system/action_logs.api';
import KTable from '@/components/KTable';
import { history } from 'umi';

export default () => {
  const columns: ProColumnType<API.ActionLog>[] = [
    {
      title: '操作人',
      dataIndex: 'admin',
      render: (_, record) => {
        return (
          <>
            <a onClick={() => history.push(`/system/users/${record.admin.id}`)}>
              {record.admin.nickname}
            </a>
            <div>{record.admin.username}</div>
          </>
        );
      },
    },
    {
      title: '备注',
      dataIndex: 'message',
      hideInSearch: true,
    },
    {
      title: '操作时间',
      dataIndex: 'created_at',
      hideInSearch: true,
    },
    {
      title: '操作IP',
      dataIndex: 'ip',
    },
  ];
  return (
    <>
      <KTable rowKey={'id'} request={apiActionLog.getList} columns={columns} />
    </>
  );
};
